/**
 * @author lonun
 * @blog http://www.lonun.com
 */

var config = require('./config');
var path = require('path');
var fs = require('fs');
var ViewEngine = function(templateType){
	this.templateType = templateType || config.templateType;
	this.templateEngine = require(templateType);
}
ViewEngine.prototype.getTemplateEngine = function(){
	return this.templateEngine;
}
ViewEngine.prototype.getTemplateType = function(){
	return this.templateType;
}
ViewEngine.prototype.render = function(filePath, data, res){
	if(this.templateType=="jade"){
		//templateEngine = require(templateType);
		var fullPath = path.join(__dirname, viewPath);
		var str = fs.readFileSync(fullPath, 'utf8');
		var fn = templateEngine.compile(str, ret);
		var resStr = fn(ret);
		res.end(resStr, "utf8");
		//templateEngine.renderFile(viewPath, ret);
	}
}
exports.ViewEngine = ViewEngine;
